package com.cq.hd.common.enums.biz;

import lombok.Getter;

import java.util.Optional;

/**
 * 银行编码
 */
public enum HfBankIdEnum {

    ZG("01040000", "中国银行"),
    ZGNY("01030000", "中国农业银行"),
    ZGGS("01020000", "中国工商银行"),
    ZGJS("01050000", "中国建设银行"),
    JT("03010000", "交通银行"),
    ZGYZCX("04030000", "中国邮政储蓄银行"),
//    HX("03040000", "华夏银行"),
    ZS("03080000", "招商银行"),
    SHPDFZ("03100000", "上海浦东发展银行"),
//    ZHES("03160000", "浙商银行"),
    GF("03060000", "广发银行"),
//    TJ("03130012", "天津银行"),
//    JN("31346100", "济宁银行"),
    ZGMS("03050000", "中国民生银行"),
    XY("03090000", "兴业银行"),
    ZX("03020000", "中信银行"),
    QZ("03133507", "泉州银行"),
    NCSY("88001394", "厦门农村商业银行股份有限公司"),
    XM("88000071", "厦门银行股份有限公司"),
    PA("03134402", "平安银行"),
    FJNCXYS("88003826", "福建省农村信用社联合社"),
    ;

    @Getter
    private final String value;

    @Getter
    private final String name;

    HfBankIdEnum(String value, String name) {
        this.value = value;
        this.name = name;
    }

    public static HfBankIdEnum typeOfValue(String value) {
        HfBankIdEnum[] values = HfBankIdEnum.values();
        for (HfBankIdEnum v : values) {
            if (v.value.equals(value)) {
                return v;
            }
        }
        return null;
    }

    public static HfBankIdEnum typeOfName(String name) {
        HfBankIdEnum[] values = HfBankIdEnum.values();
        for (HfBankIdEnum v : values) {
            if (v.name.equals(name)) {
                return v;
            }
        }
        return null;
    }

    public static String getNameByValue(String value) {
        return Optional.ofNullable(typeOfValue(value))
                .map(HfBankIdEnum::getName)
                .orElse(null);
    }

}
